#pragma once
#include "tinyrpc/base/Fd.h"
#include <memory>
#include "tinyrpc/base/buffer.h"
#include "../inetaddress.h"
#include "AbstractChannel.h"
#include "../eventloop.h"
#include <iostream>
namespace TinyRPC{

  
class SocketChannel : public AbstractChannel{
public:
    SocketChannel();
    void connect(const INetAddress& peerAddress);
    SocketChannel(int fd, const INetAddress& peerAddress);
    BufferPtr read();
    void write( BufferPtr buf);
    void write(const std::string & buffer);
    ~SocketChannel(){
        std::cout<<"SocketChannel del"<<std::endl;
    }
private:
    INetAddress m_peerAddress;
    BufferPtr m_buf;
    int m_sockFd;
};
// 通过共享指针来传递SocketChannel
using SocketChannelPtr = std::shared_ptr<SocketChannel>;
}
